import type { HttpStatus } from '@nestjs/common'
import type { NextFunction, Request, Response } from 'express'
import { HttpException } from '@nestjs/common'

class CustomException extends HttpException {
  constructor(message: string, status: HttpStatus) {
    super({ message, status }, status)
  }
}

export function contentMiddleware(
  req: Request,
  res: Response,
  next: NextFunction,
) {
  req['customException'] = CustomException

  next()
}
